package com.cheng.im.gateway.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.client.codec.Codec;
import org.redisson.client.codec.StringCodec;
import org.redisson.codec.FstCodec;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class RedissonConfig {

    @Bean
    public RedissonClient redissonClient(){
        // todo: 得改
        Config conf = new Config();
        //单节点模式
        SingleServerConfig singleServerConfig = conf.useSingleServer();
//        //设置连接地址：redis://127.0.0.1:6379
        singleServerConfig.setAddress("redis://127.0.0.1:6379");
//        //设置连接密码
//        singleServerConfig.setPassword(environment.getProperty("redisson.host.password"));
        StringCodec stringCodec = new StringCodec();
        conf.setCodec(stringCodec);
        RedissonClient redissonClient = Redisson.create(conf);
        return redissonClient;
    }
}
